<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Contnet-Type" content="text/html; charset=UTF-8">

<title>Serpantin</title>

<style type="text/css">
	@import "/site_media/dojo/dojo/resources/dojo.css";
	@import "/site_media/dojo/dijit/themes/tundra/tundra.css";
</style>

<script type="text/javascript" src="/site_media/dojo/dojo/dojo.js" djConfig = "isDebug:true, parseOnLoad:true, extraLocale:['ru-ru']"></script>
<script type="text/javascript" src="/site_media/js/serpantin.js"></script>

<script language="JavaScript" type="text/javascript">
	dojo.require("dojo.parser");
	dojo.require("dijit.form.Button");
	dojo.require("dijit.Dialog");
	dojo.require("dijit.form.TextBox");
	
	dojo.addOnLoad(function() {
		dijit.byId('dialog').show();
	});
	
	function postData(fields) {
		//alert(dojo.toJson(fields, true));
		fields.next = "{{ next }}";
		dojo.xhrPost({
			url: "/accounts/login/",
			timeout: 5000,
			content: fields,
			load: function(response, ioArgs)
			{
				// FIXME: should reload not only the whole window, 
				// but also separate content panes where appropriate
				
				//window.location.reload();
				
				window.location.href = "{{ next }}";
				return response;
			},
			error: function(response, ioArgs)
			{
				console.error("HTTP status code: ", ioArgs.xhr.status);
				return response;
			}
		});
	}
</script>

</head>

<body class="tundra">

<div dojoType="dijit.Dialog" id="dialog" title="Autentication required" execute="postData(arguments[0]);">
<table>
	<tr>
		<td><label for="id_username">Username: </label></td>
		<td><input dojoType="dijit.form.TextBox" id="id_username" type="text" name="username"></td>
	</tr>
	<tr>
		<td><label for="id_password">Password: </label></td>
		<td><input dojoType="dijit.form.TextBox" id="id_password" type="password" name="password"></td>
	</tr>
	<tr>
		<td colspan="2" align="center">
		<button dojoType=dijit.form.Button type="submit">OK</button></td>
	</tr>
</table>
</div>

<!-- Old password form, is being kept here for reference
{% if form.has_errors %}
	<p>Your username and password didn't match. Please try again.</p>
{% endif %}

<form method="post">
	<table>
	<tr><td><label for="id_username">Username:</label></td><td>{{ form.username }}</td></tr>
	<tr><td><label for="id_password">Password:</label></td><td>{{ form.password }}</td></tr>
	</table>
	
	<input type="submit" value="login">
	<input type="hidden" name="next" value="{{ next }}">
</form>
-->
</body>
</html>
